<?php
include '../wp-blog-header.php';
/* Unique Id for CSS Blocks Avoids other ppl tryin to overide our CSS */
$uniqid = uniqid();
/* Unique Id for CSS Blocks */

$url_page = $_GET['pg'];
$url_category = $_GET['c'];
$url_city = $_GET['l'];
if(empty($url_city)){
$url_city = 'Mumbai';
}


/* Decryption & Variable Assignment etc... */
//$param = '7IQYW1PTRGooWPT5uW1PTHu3Q5SA8Qt8AMQNnwdyv54vVw6qVWPTHvqCklUk4awnMDzxUMSQxbxW1PTWPTuYNrQXIXAXTYNO2GxipqxKyxB5dnLL4XebANaMWPTDQNgxdJwEGvvbtS5X4W1PTylPUQC1U3VWPTFXeIfmcmkZWPTvMwUpUmr5IyoTb2Iy10jbTUcti1tVhkd2BopcGsbmCOgQi4H1l4LC1DgTeuRiGRkQCvNNGA7kuVJMDarF7PFcBRT3TCWPTSKL6nxKeqALfWPTUWoTatqp9et9';

$param = '8fGffReFRtjBiw33iXzYfhv9YKXa2sH1jIxcXCOkQnRTqGhWPTMkWxZ1EU7VDAROhnEVMAgy99kY8xR213gTEFHSIapqjl76EEcrDzedgWCPQmt6HJ1bgCCergTKWPTeRAH2mKHunW1PTuVtzINyGuBE1dfyzz8Hln4byxWFOQ5lPlCAUy8WlMdx9dNBRGeFtf5u3W1PTri12BlaW1PTpl4dTvpTesofLb2SxuAMkuaTnG8Nfa3Q=';

$decrypted_param = decrypt($param,'1b2u3z4z5r6');
//echo $param;
$decrypted_param = explode('$',$decrypted_param);
//print_r($decrypted_param);
//exit();

//$params = 'name=deal&format=json';
$params = $decrypted_param[0];


if(empty($url_category) && !empty($url_city)){
	$title = '<h1 class="page_title">Featured Deals in '.$url_city.' </h1>';
	$params = $params.'&items=6&type=afternoon';
}else{
	$params = $params.'&items=12&type=sale,daily';
}

/* Filter Pagination */
if(!empty($url_page)){
$params = $params.'&page='.$url_page;
}
else{
$url_page = 1;
}
/* Filter Pagination */

/* Filter Catgeory */
if(!empty($url_category)){
$params = $params.'&category='.urlencode($url_category);
}
/* Filter Catgeory */

/* Filter City */
if(!empty($url_city)){
$params = $params.'&cities='.urlencode($url_city);
}
/* Filter City */

//$fields = 'title,deal_link,image,store,category,city,map,ads,poweredby,ends';
$fields = $decrypted_param[1];
//$look = 'wrap_width=900px,unit_background=#F3F3F3';
$look = $decrypted_param[2];

//$api = '4e05b994d7005';
$api_key = $decrypted_param[3];

//$tp = encrypt($params.'$'.$fields.'$'.$look.'$'.$api,'1b2u3z4z5r6');
//echo 'http://buzzr.in/wordpress/buzzr_whitelabel.php?p='.$tp;
//exit();

/* Decryption & Variable Assignment etc... */


/* API Key Validation */
if(!empty($api_key))
{
  $api_pod = new Pod('api');
  $api_pod->page = 1;
  $api_pod->search = 1;
  $api_pod->findRecords('id DESC', -1, "t.api_key ='$api_key'");
  $api_exists = $api_pod->getTotalRows();
  if($api_exists > 0)
  {
    while($api_pod->fetchRecord()){
      $client_name = $api_pod->get_field('name');
      $client_name = explode('_',$client_name);
      $client_name = $client_name[0];    
    }
  }
}
/* API Key Validation */

/* If Api Key is Valid Then Proceed */
if($api_exists > 0)
{

/* Whitelabel Clients Params */
$fields = explode(',',$fields);

$look = explode(',',$look);

foreach($look as $vlook){
  $param_look = explode('=',$vlook);
  switch($param_look[0]){
    case 'wrap_width':
      $wrap_width = $param_look[1];
      break;
    case 'unit_background':
      $unit_background = $param_look[1];
      break;
  } 
}

if(empty($wrap_width)){
  $wrap_width = '700px';
}

if(empty($unit_background)){
$unit_background = '#F3F3F3';
}
/* Whitelabel Clients Params */

/* Whitelabel Clients Offers */
function download_page($path){
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL,$path);
        curl_setopt($ch, CURLOPT_FAILONERROR,1);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
        curl_setopt($ch, CURLOPT_TIMEOUT, 60);
        $retValue = curl_exec($ch);                      
        curl_close($ch);
        return $retValue;
}
$url = BUZZR_URL.'/api2/?'.$params.'&apikey='.$api_key;
$curl_json_output = download_page($url);
//$curl_json_output = file_get_contents($url);
//echo $url;
$json_decoded = json_decode($curl_json_output, true);
/*
echo "<pre>";
print_r($json_decoded);
exit();
*/
/* Whitelabel Clients Offers */
?>
<html>
<head>
<title>Afternoon DC <?php echo $url_city; ?> Offers </title>
<link rel="shortcut icon" href="http://afternoondc.in/images/favicon.ico" />

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-1717133-11']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>

<style>
body{
	margin:0;
	padding:0;
	background-color:#bdbdbd;
}

.content{
	margin:0 auto;
	width:979px;
	background-color:#fff;
	padding: 0 10px;
}

#logo{
	float:left;
	margin-top:14px;
	margin-bottom:10px;
}

#logo a{
text-decoration: none;
}

#logo img{
	width:368px;
	height:94px;
	border: none;
	
}

#adctitle{
	float:right;
	margin-top:14px;
	margin-bottom:10px;
}

#adctitle img{
	width:550px;
	height:94px;
}

#searchBar{
	float:right;
}

#searchBar .redtextb{
	color:#d90f17;
	float:left;
	font-family:Arial,sans-serif;
	font-size:12px;
	font-weight:bold;
	line-height:21px;
	text-decoration:none;
	width:60px;
}

#searchBar .searchdrop{
	float:left;
	width:136px
}

.field{
	background-color:#f4f4f4;
	border-color:#ccc;
	border-style:solid;
	border-width:1px;
	color:#000;
	font-family:Arial,sans-serif;
	font-size:12px;
	width:130px;
}

#searchBar .searchfield{
	float:left;
}

#searchBar .searchbtn{
	float:left;
	background-color:#c00;
	color:#fff;
	font:12px Arial;
	border:1px solid #ddd;
}

#mainMenu{
	width:979px;
	margin:auto;
	height:27px;
	background-color:#5b5a54;
}

.menutd{
	font-family:Arial,sans-serif;
	font-size:11px;font-weight:bold;
	line-height:27px;color:#f0eeee;
	text-decoration:none;
	text-transform:uppercase;
	float:left;
	background-color:#5b5a54;
}

.menutd A:link{
	color:#f0eeee;
	text-decoration:none;
}

.menutd A:visited{
	color:#f0eeee;
	text-decoration:none;
}

.menutd A:active{
	color:#f0eeee;
	text-decoration:none;
}

.menutd A:hover{
	color:#f0eeee;
	text-decoration:none;
}

.menuselectedtd{
	font-family:Arial,sans-serif;
	font-size:11px;
	font-weight:bold;
	background-color:#c20;
	line-height:27px;
	color:#f0eeee;
	float:left;
	text-transform:uppercase;
}

.menuselectedtd a{
	color:#f0eeee;
	text-decoration:none;
}

#quicklinks{
	font-family:Arial,sans-serif;
	font-weight:bold;
	background-color:#d5d5d5;
	font-size:10px;
	line-height:22px;
	color:#5f5e58;
	margin:auto;
	margin-bottom:15px;
	width: 979px;
}

#quicklinks .redtextb{
	font-family:Arial,sans-serif;
	font-size:12px;
	font-weight:bold;
	padding-left:5px;
	height:22px;
	color:#d90f17;
	text-decoration:none;
	float:left;
}

#quicklinks a{
	text-transform:uppercase;
	color:#5f5e58;
	text-decoration:none;
}

.redgradbgth{
	font-family:Arial,sans-serif;
	font-size:12px;
	font-weight:bold;
	padding-left:10px;
	padding-right:10px;
	background-image:url(images/redgradthbg.gif);
	line-height:25px;
	color:#fff;
	width:160px;
}

.graytd{
	font-family:Arial,sans-serif;
	font-size:11px;
	font-weight:normal;
	padding-left:10px;
	padding-right:10px;
	padding-top:10px;
	padding-bottom:10px;
	background:#dfdede;
	color:#5f5e58;
	width:160px;
}

.epaper_nav{
	font-family:Arial,sans-serif;
	font-size:11px;
	font-weight:normal;
	background:#dfdede;
	color:#5f5e58;
	border-bottom:1px solid #696969;
}

.epaper_nav a{
	text-decoration:none;
	color:#5f5e58;
	display:block;
	padding-left:10px;
	padding-right:10px;
	padding-top:6px;
	padding-bottom:6px;
}

.sf-menu,.sf-menu *{
	list-style:none outside none;
	margin:0;
	padding:0;
}
.sf-menu{
	line-height:1;

}

.sf-menu ul{
	position:absolute;
	top:-999em;
	width:10em;
}

.sf-menu ul li{
	width:100%;
}

.sf-menu li:hover{
	visibility:inherit;
}

.sf-menu li{
	float:left;
	position:relative;
}

.sf-menu a{
	display:block;
	position:relative;
}

.sf-menu li:hover ul,.sf-menu li.sfHover ul{
	left:0;
	top:1.8em;
	z-index:99;
}

ul.sf-menu li:hover li ul,ul.sf-menu li.sfHover li ul{
	top:-999em;
}

ul.sf-menu li li:hover ul,ul.sf-menu li li.sfHover ul{
	left:10em;
	top:0;
}

ul.sf-menu li li:hover li ul,ul.sf-menu li li.sfHover li ul{
	top:-999em;
}

ul.sf-menu li li li:hover ul,ul.sf-menu li li li.sfHover ul{
	left:10em;
	top:0;
}

.sf-menu{
	float:left;
}

.sf-menu a{
	color:#696969;
	text-decoration:none;
}

.sf-menu a,.sf-menu a:visited{
	color:#696969;
}

.sf-menu li li{
	background:none repeat scroll 0 0 #f9f9f9;
	border-top:1px solid #eee;
	display:block;
}

.sf-menu li li a{
	padding-bottom:10px;
	padding-left:10px;
	padding-top:10px;
}

.sf-menu li li a:hover{
	background:none repeat scroll 0 0 #eee;
	display:block;
}

.sf-menu a.sf-with-ul{
}

.sf-sub-indicator{
}

a>.sf-sub-indicator{
	background-position:0 -100px;
	top:0.8em;
}

a:focus>.sf-sub-indicator,a:hover>.sf-sub-indicator,a:active>.sf-sub-indicator,li:hover>a>.sf-sub-indicator,li.sfHover>a>.sf-sub-indicator{
background-position:-10px -100px;
}

.sf-menu ul .sf-sub-indicator{
	background-position:-10px 0;
}

.sf-menu ul a>.sf-sub-indicator{
	background-position:0 0;
}

.sf-menu ul a:focus>.sf-sub-indicator,.sf-menu ul a:hover>.sf-sub-indicator,.sf-menu ul a:active>.sf-sub-indicator,.sf-menu ul li:hover>a>.sf-sub-indicator,.sf-menu ul li.sfHover>a>.sf-sub-indicator{
	background-position:-10px 0;
}

.sf-shadow ul{
	background:url(images/shadow.png) no-repeat scroll right bottom transparent;
	border-bottom-left-radius:17px;
	border-top-right-radius:17px;
	padding:0 8px 9px 0;
}

.sf-shadow ul.sf-shadow-off{
	background:none repeat scroll 0 0 transparent;
	}


.title_<?php echo $uniqid; ?>{
	font-size:18px;
	padding:10px;
	height:65px;
}

.page_title{
	font: bold 14px Arial;
color: #5B5A54;
padding: 0;
border-bottom: 1px solid gray;
margin: 0 0 20px 0;
}

.unit_wrapper_<?php echo $uniqid; ?>{
	width:516px;
	float:left;
}

.unit_ads_<?php echo $uniqid; ?>{
	min-height:60px;
	text-align:center;
	border:1px solid #ddd;
	margin-bottom:15px;
	padding:5px;
}

.unit_<?php echo $uniqid; ?>{
	margin-bottom:15px;
	height:260px;
	background-color:#ededed;
	width:157px;
	float:left;
	margin-left:15px;
}

.unit_<?php echo $uniqid; ?> a{
	color:#303030;
	font-family:Arial,sans-serif;
	font-size:12px;
	font-weight:bold;
}

.unit_<?php echo $uniqid; ?> a:hover{
	color:#000;
}

.unit_<?php echo $uniqid; ?> img{
	width:100px;
	height:100px;
}

a{
	text-decoration:none;
}

.image_<?php echo $uniqid; ?>{
	text-align:center;
	margin:5px 0px;
}

.cat_<?php echo $uniqid; ?>{
	background-color:#c00;
	padding:5px;
}

.cat_<?php echo $uniqid; ?> a{
	color:#fff;
	font:bold 12px Arial;
}

.cat_list_<?php echo $uniqid; ?> a{
	color:#000;
	font-size:12px;
	font-weight:bold;
	margin-right:4px;
}

.cat_<?php echo $uniqid; ?> a:hover,.cat_list_<?php echo $uniqid; ?> a:hover{
}

.cat_name{
	background-color:#ededed;
	padding:2px 5px;
	margin-bottom:10px;
}

.powered_<?php echo $uniqid; ?>{
	text-align:center;
	margin-top:20px;
}

.powered_<?php echo $uniqid; ?> a{
	font-family:Arial,Helvetica,sans-serif;
	font-size:11px;
}

.powered_<?php echo $uniqid; ?> img,.unit_<?php echo $uniqid; ?> img{
	border:none;
}

.paginate_<?php echo $uniqid; ?>{
	margin-top:10px;
	font-size:16px;
	text-align:center;
	font-family:Arial,Helvetica,sans-serif;
}

.cat_list_<?php echo $uniqid; ?>{
	background-color:#dfdede;
	padding:5px;
	font-family:Arial,Helvetica,sans-serif;
	font-size:12px;
	font-weight:bold;
	text-align:left;
}

.cat_list_<?php echo $uniqid; ?> p{
	font:18px Arial;
	color:#fff;
}

.left-float{
	float:left;
	margin-right:10px;
}

.ads_sidebar_<?php echo $uniqid; ?>{
	float:right;
	width:28%;
	padding:5px;
	font-size:18px;
	text-align:center;
	background-color:#f2f2f2;
}

.no_offer_<?php echo $uniqid; ?>{
	color:maroon;
	font-size:20px;
	min-height:20px;
	text-align:center;
}

.banner{
	margin-top:10px;
	height:70px;
	border:1px solid;
}

.head{
	height:88px;
}

.logo{
	width:128px;
	float:left;
}

.reader{
	width:760px;
	float:left;
}

.subscribe,.result{
	float:right;
	width:28%;
	margin-top:15px;
	padding:5px;
	font-family:Arial,Helvetica,sans-serif;
	font-size:12px;
	font-weight:bold;
	text-align:left;
	background-color:#f2f2f2;
}

.result{
	display:none;
	background-color:#ffffe0;
	text-align:center;
}

#email{
	margin-top:5px;
	margin-bottom:5px;
}

.deal_expiry{
	padding: 5px;
font: 12px Arial;
width: 147px;
height: 24px;
}

</style>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script type="text/javascript">
function cdtime(container, targetdate){
if (!document.getElementById || !document.getElementById(container)) return
this.container=document.getElementById(container)
this.currentTime=new Date()
this.targetdate=new Date(targetdate)
this.timesup=false
this.updateTime()
}

cdtime.prototype.updateTime=function(){
var thisobj=this
this.currentTime.setSeconds(this.currentTime.getSeconds()+1)
setTimeout(function(){thisobj.updateTime()}, 1000) //update time every second
}

cdtime.prototype.displaycountdown=function(baseunit, functionref){
this.baseunit=baseunit
this.formatresults=functionref
this.showresults()
}

cdtime.prototype.showresults=function(){
var thisobj=this

var timediff=(this.targetdate-this.currentTime)/1000 //difference btw target date and current date, in seconds
if (timediff<0){ //if time is up
this.timesup=true
this.container.innerHTML=this.formatresults()
return
}
var oneMinute=60 //minute unit in seconds
var oneHour=60*60 //hour unit in seconds
var oneDay=60*60*24 //day unit in seconds
var dayfield=Math.floor(timediff/oneDay)
var hourfield=Math.floor((timediff-dayfield*oneDay)/oneHour)
var minutefield=Math.floor((timediff-dayfield*oneDay-hourfield*oneHour)/oneMinute)
var secondfield=Math.floor((timediff-dayfield*oneDay-hourfield*oneHour-minutefield*oneMinute))
if (this.baseunit=="hours"){ //if base unit is hours, set "hourfield" to be topmost level
hourfield=dayfield*24+hourfield
dayfield="n/a"
}
else if (this.baseunit=="minutes"){ //if base unit is minutes, set "minutefield" to be topmost level
minutefield=dayfield*24*60+hourfield*60+minutefield
dayfield=hourfield="n/a"
}
else if (this.baseunit=="seconds"){ //if base unit is seconds, set "secondfield" to be topmost level
var secondfield=timediff
dayfield=hourfield=minutefield="n/a"
}
this.container.innerHTML=this.formatresults(dayfield, hourfield, minutefield, secondfield)
setTimeout(function(){thisobj.showresults()}, 1000) //update results every second
}

/////CUSTOM FORMAT OUTPUT FUNCTIONS BELOW//////////////////////////////

//Create your own custom format function to pass into cdtime.displaycountdown()
//Use arguments[0] to access "Days" left
//Use arguments[1] to access "Hours" left
//Use arguments[2] to access "Minutes" left
//Use arguments[3] to access "Seconds" left

//The values of these arguments may change depending on the "baseunit" parameter of cdtime.displaycountdown()
//For example, if "baseunit" is set to "hours", arguments[0] becomes meaningless and contains "n/a"
//For example, if "baseunit" is set to "minutes", arguments[0] and arguments[1] become meaningless etc


function formatresults(){
if (this.timesup==false){//if target date/time not yet met
var displaystring= arguments[0]+" days "+arguments[1]+":"+arguments[2]+":"+arguments[3]
}
else{ //else if target date/time met
var displaystring="This offer has expired"
}
return displaystring
}

function formatresults2(){
if (this.timesup==false){ //if target date/time not yet met
var displaystring="<span class='lcdstyle'>Time Left:<br/> "+arguments[0]+" days "+arguments[1]+":"+arguments[2]+":"+arguments[3]+"</span>"
}
else{ //else if target date/time met
var displaystring="This offer has expired" //Don't display any text
}
return displaystring
}
</script>
<script type="text/javascript">
		jQuery.noConflict();
</script>
</head>
<body>
<div class="content">
		<div id="logo" style="padding-left:13px; border-bottom: 1px solid;">
          <a href="http://afternoondc.in"><img src="images/afternoon_logo.jpg"></a>
        </div><a>
	   <div id="adctitle" style="padding-left:13px;">
          <img src="images/afternoon-header.png">
        </div>
 <div style="clear: both;"></div>
 </a><div id="mainMenu">
		<div id="header1_rptMenu_ctl10_pnlMenu" class="menutd">
	<a href="http://www.afternoondc.in">&nbsp;&nbsp;Home&nbsp;&nbsp;</a>  </div>
		    <div id="header1_rptMenu_ctl00_pnlMenu" class="menutd">
	<a href="http://www.afternoondc.in/city-news">&nbsp;&nbsp;City news&nbsp;&nbsp;</a>
</div>
		    <div id="header1_rptMenu_ctl01_pnlMenu" class="menutd">
	<a href="http://www.afternoondc.in/sports">&nbsp;&nbsp;Sports&nbsp;&nbsp;</a>
</div>
		    <div id="header1_rptMenu_ctl02_pnlMenu" class="menutd">
	<a href="http://www.afternoondc.in/business">&nbsp;&nbsp;Business&nbsp;&nbsp;</a>
</div>
		    <div id="header1_rptMenu_ctl03_pnlMenu" class="menutd">
	<a href="http://www.afternoondc.in/editorial">&nbsp;&nbsp;Editorial&nbsp;&nbsp;</a>
</div>
		    <div id="header1_rptMenu_ctl04_pnlMenu" class="menutd">
	<a href="http://www.afternoondc.in/techno-stuff">&nbsp;&nbsp;Techno Stuff&nbsp;&nbsp;</a>
</div>
		    <div id="header1_rptMenu_ctl05_pnlMenu" class="menutd">
	<a href="http://www.afternoondc.in/nation">&nbsp;&nbsp;Nation&nbsp;&nbsp;</a>
</div>
		    <div id="header1_rptMenu_ctl06_pnlMenu" class="menutd">
	<a href="http://www.afternoondc.in/television">&nbsp;&nbsp;Television&nbsp;&nbsp;</a>
</div>
		    <div id="header1_rptMenu_ctl07_pnlMenu" class="menutd">
	<a href="http://www.afternoondc.in/bollywood">&nbsp;&nbsp;Bollywood&nbsp;&nbsp;</a>
</div>
		    <div id="header1_rptMenu_ctl08_pnlMenu" class="menutd">
	<a href="http://www.afternoondc.in/hollywood">&nbsp;&nbsp;Hollywood&nbsp;&nbsp;</a>
</div>
		    <div id="header1_rptMenu_ctl09_pnlMenu" class="menutd">
	<a href="http://www.afternoondc.in/brush-with-art">&nbsp;&nbsp;Brush With Art&nbsp;&nbsp;</a>
</div>
		    <div id="header1_rptMenu_ctl10_pnlMenu" class="menutd">
	<a href="http://www.afternoondc.in/interview">&nbsp;&nbsp;Interview&nbsp;&nbsp;</a>
	</div>
	<div class="menuselectedtd"><a href="./Afternoon_files/Afternoon.htm">&nbsp;&nbsp;Offers&nbsp;&nbsp;</a></div>
	<div id="header1_rptMenu_ctl10_pnlMenu" class="menutd">
	<a href="http://www.afternoondc.in/epaper/default.aspx">&nbsp;&nbsp;Epaper&nbsp;&nbsp;</a>  </div>
</div>
	<div class="clear"></div>
   <div id="quicklinks">
	    <div style="float:left;border-right:1px solid #696969;padding-right:10px">
	    <ul class="sf-menu redtextb">
	        <li><div style="cursor:pointer;padding-top:5px;">Special Section</div>
	        <ul style="width:170px;">
	        <li><a href="http://www.afternoondc.in/business-investment">Business &amp; Investment</a></li>
            <li><a href="http://www.afternoondc.in/health-fitness">Health &amp; Fitness</a></li>
            <li><a href="http://www.afternoondc.in/education-careers">Education &amp; Careers</a></li>
            <li><a href="http://www.afternoondc.in/womens-world">Woman's World</a></li>
            <li><a href="http://www.afternoondc.in/48-hrs">48 Hrs</a></li>
            <li><a href="http://www.afternoondc.in/property-interior">Property &amp; Interior</a></li>
	        </ul>
	        </li>
	        </ul></div>
	        <span class="redtextb">&nbsp;&nbsp;Quick Links &gt;&gt;&nbsp;&nbsp;</span>
		     <a href="http://www.afternoondc.in/town-about">&nbsp;&nbsp;Town &amp; About&nbsp;&nbsp;</a>
		    | <a href="http://www.afternoondc.in/film-review">&nbsp;&nbsp;Film Review&nbsp;&nbsp;</a>
		    | <a href="http://www.afternoondc.in/leisure">&nbsp;&nbsp;Leisure&nbsp;&nbsp;</a>
		    | <a href="http://www.afternoondc.in/book-review">&nbsp;&nbsp;Book Review&nbsp;&nbsp;</a>
		    | <a href="http://www.afternoondc.in/spectrum">&nbsp;&nbsp;Spectrum&nbsp;&nbsp;</a>
		    | <a href="http://www.afternoondc.in/feature">&nbsp;&nbsp;Feature&nbsp;&nbsp;</a>
		    | <a href="http://www.afternoondc.in/tv-guide">&nbsp;&nbsp;TV Guide&nbsp;&nbsp;</a>
		    | <a href="http://www.afternoondc.in/coffee-break">&nbsp;&nbsp;Coffee Break&nbsp;&nbsp;</a>
		    | <a href="http://www.afternoondc.in/classified">&nbsp;&nbsp;Classified&nbsp;&nbsp;</a>
</div>

<!-- Whitelabel Content Wrap -->
<div id="whitelabel_wrap_<?php echo $uniqid; ?>">
     <div class="left-float">    
     <?php
      /* City Dropdown */
      if(in_array('city',$fields)){
        $o.= '<div class="cat_list_'.$uniqid.'"><select name="city_select" onchange="window.location.href = this.value;">';
        $o.= '<option value="#">-- Choose City --</option>';
        $city_pod = new Pod('city');
        $city_pod->page = 1;
        $city_pod->search = false;
        $city_pod->findRecords('name ASC', -1);
        while($city_pod->fetchRecord()){
           $citname = $city_pod->get_field('name');
           if(!empty($url_category)){
            $citlink = 'http://afternoon.buzzr.in/index.php?c='.$url_category.'&l='.$citname;
           }
           else{
            $citlink = 'http://afternoon.buzzr.in/index.php?l='.$citname;
           }
           
           /* Checks for the Selected City to show as Selected in DropDown else populates other options */
           if($citname == $url_city){
            $o.= '<option selected="selected" value="'.$citlink.'">'.$citname.'</option>';
           }
           else{
            $o.= '<option value="'.$citlink.'">'.$citname.'</option>';
           }
           /* Checks for the Selected City to show as Selected in DropDown */
        }
    	  $o.= '</select></div>';
		  
    	  echo $o;
      } 
     ?>

     <?php
      /* Category Listing */
      if(in_array('category',$fields)){
     ?>
      <!-- Category Listing -->
	 <p style="background-color: #CC2200; color: #FFFFFF; margin-bottom: 0; padding-left: 5px; font: bold 12px/25px Arial, sans-serif;">Categories</p>
     <div class="cat_list_<?php echo $uniqid; ?>">
		<div class="cat_name"><a href="<?php echo 'http://afternoon.buzzr.in/index.php?l='.$url_city; ?>">Featured</a></div>
     <?php
      $category_pod = new Pod('category');
      $category_pod->page = 1;
      $category_pod->search = false;
      $category_pod->findRecords('name ASC', -1,"is_local = 1 OR is_daily = 1");
      while($category_pod->fetchRecord()){
         $cname = $category_pod->get_field('name');
		 
         if(!empty($url_city)){
          $clink = 'http://afternoon.buzzr.in/index.php?l='.$url_city.'&c='.sanitize_title($cname);
         }
         else{
          $clink = 'http://afternoon.buzzr.in/index.php?c='.sanitize_title($cname);
         }
           
          echo '<div class="cat_name"><a href="'.$clink.'">'.$cname.'</a></div>';
      }
     ?>
     </div>
     <!-- Category Listing -->
     <?php } ?>
        <div class="powered_<?php echo $uniqid; ?>"><a target="_blank" href="http://enthrallmedia.com"><img src="images/buzzr_platform.png" width="130px" height="27px"/></a></div>
     </div>
     <?php if(count($json_decoded) > 0){ ?>
     <!-- Deal Units Wrap -->
     <div class="unit_wrapper_<?php echo $uniqid; ?>">
     <?php 
     /* Deals Loop */
     //asort($json_decoded);
	 if(!empty($title)){
	 echo $title;
	 }
     foreach($json_decoded as $key=>$value){
      
      /* Ads Unit */
      if(in_array('ads',$fields)){
         if(($key == (count($json_decoded) - 3)) || $key == 3){
         echo '<div style="clear: both;"></div><div class="unit_ads_'.$uniqid.'">';
         $ads_unit_width = 0.61 * (str_replace('px','',$wrap_width));
         if($ads_unit_width > 468){
             echo '<script type="text/javascript"><!--
				google_ad_client = "ca-pub-3655588719499040";
				/* Afternoon Banner */
				google_ad_slot = "3625470962";
				google_ad_width = 468;
				google_ad_height = 60;
				//-->
				</script>
				<script type="text/javascript"
				src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
				</script>';
          }
          else{
            echo '<script type="text/javascript"><!--
				google_ad_client = "ca-pub-3655588719499040";
				/* Afternoon Square */
				google_ad_slot = "0673516983";
				google_ad_width = 250;
				google_ad_height = 250;
				//-->
				</script>
				<script type="text/javascript"
				src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
				</script>';
						  } 
         echo '</div>';
         }
       }
       /* Ads Unit */
       ?>
       
       <!-- Deal Unit --> 
       <div class="unit_<?php echo $uniqid; ?>">
        <?php 
          $deal_name = $value['offer_name']; //replace with api owners name
          //$deal_link = $value['offer_link']."?utm_source=whitelabel_offers&utm_medium=whitelabel&utm_campaign=$client_name";
          $deal_link = $value['offer_red_link'];
		  if(empty($deal_link)){
			$deal_link = $value['offer_link'];
		  }
		  //$cat_link = $value['offer_categories_url']."?utm_source=whitelabel_offers&utm_medium=whitelabel&utm_campaign=$client_name";
		  $cat_link = $value['offer_categories_url'];
        ?>
		
		<?php
          /* Deal Cat */
          if(in_array('category',$fields)){
            $deal_cat_name = $value['offer_categories'];
        ?>
        <div class="cat_<?php echo $uniqid; ?>"><a target="_blank" href="<?php echo $cat_link; ?>"><?php if(!empty($deal_cat_name)){ echo $deal_cat_name;}else{echo 'Shopping';} ?></a></div>
        <?php } /* Deal Cat */ ?>  
        
        <?php
          /* Deal Image */
          if(in_array('image',$fields)){
            $image = $value['offer_image_url'];
            if(empty($image)){
              $image = $value['offer_other_image'];
            }
            if(empty($image)){
              $image = $value['offer_brand_image'];
            }
        ?>
        <div class="image_<?php echo $uniqid; ?>"><a target="_blank" href="<?php echo $deal_link; ?>"><img src="<?php echo $image; ?>" /></a></div>
        <?php } /* Deal Image */ ?>
        
        <?php
          /* Deal Title */
          if(in_array('title',$fields)){
            $deal_name = $value['offer_name'];
        ?>
        <div class="title_<?php echo $uniqid; ?>"><a target="_blank" href="<?php echo $deal_link; ?>"><?php echo substr($deal_name,0,75).'...'; ?></a></div>
        <?php } ?>
        
        
        
        <?php
          /* Deal End */
          if(in_array('ends',$fields)){
            $deal_end = $value['offer_end_date'];
        ?>
		<!--[if !IE]><!-->

		<div class="deal_expiry">
        <span id="expire_<?php echo $key; ?>" class="expire_<?php echo $uniqid; ?>"></span>
        <script type="text/javascript">
         var expiry = new cdtime("expire_<?php echo $key; ?>", "<?php echo date('F j, Y, G:i:s',strtotime($deal_end)); ?>");
         expiry.displaycountdown("days", formatresults2);  
        </script>
		</div>
		
		<!--<![endif]-->

      <?php } /* Deal End */ ?>
      
     </div>
     <!-- Deal Unit -->
    
     <?php } ?>
     </div>
     <!-- Deal Units Wrap -->
	 <?php if(($key == (count($json_decoded) - 3)) || $key == 3){ ?>
		<div style="clear"></div>
	<?php	} ?>
	 
     <?php 
     }
     else{
     ?>
     <div class="unit_wrapper_<?php echo $uniqid; ?>" style="min-height:180px;">
      <div class="unit_<?php echo $uniqid; ?> no_offer_<?php echo $uniqid; ?>">Sorry no offers active</div>
     </div>
     <?php } /* Deals Loop */ ?>
     
     <?php
    /* Ads Sidebar */
    if(in_array('ads',$fields) && count($json_decoded) != 0){
    $ads_sidebar_width = 0.36 * (str_replace('px','',$wrap_width));
    if($ads_sidebar_width >= 250){
    ?>
    <div class="ads_sidebar_<?php echo $uniqid; ?>">
      <script type="text/javascript"><!--
      google_ad_client = "ca-pub-3655588719499040";
      /* Timeout Square */
      google_ad_slot = "4926107152";
      google_ad_width = 250;
      google_ad_height = 250;
      //-->
      </script>
      <script type="text/javascript"
      src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
      </script>
    </div>
    <?php 
    }
    else{
    ?>
	<div style="clear: both;"></div>
    <div class="ads_sidebar_<?php echo $uniqid; ?>">
    <script type="text/javascript"><!--
      google_ad_client = "ca-pub-3655588719499040";
      /* Buzzr Whitelabel Network 200 */
      google_ad_slot = "0360390834";
      google_ad_width = 200;
      google_ad_height = 200;
      //-->
      </script>
      <script type="text/javascript"
      src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>
    </div>
    
    
    <?php
      }
    } /* Ads Sidebar */ ?>
     <div class="subscribe">
      <b>Sign up for daily <?php echo $url_city ?> deals from Buzzr.in:</b>
      <input id="email" type="text" value="Your email ID" size="35"><br/>
      <input id="subscribe" type="button" value="Subscribe" >&nbsp;&nbsp;<span class="loading"><img src="<?php echo get_bloginfo('wpurl').'/wp-content/pfiles/images/loader.gif'; ?>" /></span>
    </div>
    <div class="result"></div> 
     <div style="clear:both;"></div>
     
    <!-- Paginate -->
    <?php
        if(count($json_decoded) != 0){
         /* Next Page Link */
         $next_page_link = 'http://afternoon.buzzr.in/index.php?pg='.($url_page + 1);
         
         if(!empty($url_city)){
          $next_page_link = $next_page_link.'&l='.$url_city;
         }
         
         if(!empty($url_category)){
          $next_page_link = $next_page_link.'&c='.$url_category;
         }
         /* Next Page Link */
       } 
       /* Prev Page Link */
       if($url_page > 1){
        $prev_page_link = 'http://afternoon.buzzr.in/index.php?pg='.($url_page - 1);
        
        if(!empty($url_city)){
          $prev_page_link = $prev_page_link.'&l='.$url_city;
        }
       
        if(!empty($url_category)){
          $prev_page_link = $prev_page_link.'&c='.$url_category;
        }
       }
       /* Prev Page Link */
    ?>
    <div class="paginate_<?php echo $uniqid; ?>">
		<?php if(!empty($prev_page_link)){ ?>
			<a href="<?php echo $prev_page_link; ?>">&lt;&lt; Prev Offers</a> | 
		<?php } if(!empty($url_category)){ if(count($json_decoded) != 0){ ?>
			<a href="<?php echo $next_page_link; ?>">More Offers &gt;&gt;</a>
		<?php } } ?>
	</div>
    <!-- Paginate -->
    
    <?php
    /* Powered by */
    if(in_array('poweredby',$fields)){
    unset($powered_link);
   // $powered_link = get_bloginfo('url')."?utm_source=whitelabel_offers&utm_medium=whitelabel&utm_campaign=$client_name";
    ?>
    <div class="powered_<?php echo $uniqid; ?>"><a target="_blank" href="http://buzzr.in">Deals provided by Buzzr.in</a></div>
    <?php } /* Powered by */ ?>
    
</div>

</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
  function isValidEmailAddress(emailAddress) {
    var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
    return pattern.test(emailAddress);
    };
 
  
  $('.loading').hide().ajaxStart(function() {
    $('.result').hide();            
        $(this).show();
    }).ajaxStop(function() {
            $(this).hide();
        $('.result').show();
    });
  
  $("#email").focus(function (){
    var value = $("#email").val();
    if(value == 'Your email ID'){
    $("#email").val('');
    }
  });

  $('#email').blur(function() {
    var value = $("#email").val();
    if(value == ''){
    $("#email").val('Your email ID');
    }
  });

  $('#subscribe').click(function() {
   var email = $('#email').val();
   if(email==''){
     alert('Please enter your email ID');
   }
   else{
     var is_valid = isValidEmailAddress(email);
     if(is_valid === true){
      $.ajax({
        	type: "post",
        	url: "http://afternoon.buzzr.in/subscribe.php",
          data: "buzzr_email="+email,
        	success: function(msg){
            //$('.result').empty();
            //$('.result').append(msg);
        	}
        });
     }
     else{
     alert('Please enter a valid email address');
     }
   }
  
  });

});
</script>
</body>
</html>
<!-- Whitelabel Content Wrap -->

<?php
}
/* If Api Key is Valid Then Proceed */

/* If Api Key is NotValid Then Error */
else{
  echo 'Sorry there seems to be some trouble with your api key, please contact us at <a href="mailto:info@enthrallmedia.com">mailto:info@enthrallmedia.com</a>';
}
/* If Api Key is NotValid Then Error */
?>